#!/bin/bash
# chkconfig: 2345 99 01
# description: Simple http server for slb test.

prog="httpterm"
exec=/root/httpterm-s
pidfile=/var/run/httpterm.pid
config=/root/httpterm.cfg

. /etc/init.d/functions

case "$1" in
    start)
        $exec -f $config -dS -D
        echo $(pidof $exec) > $pidfile
        ;;
    stop)
        kill `cat $pidfile`
        rm $pidfile
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    status)
        if [ -e $pidfile ]; then
            echo $prog is running, pid=`cat $pidfile`
        else
            echo $prog is NOT running
            exit 1
        fi
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 2
esac
exit $?
